'''
7.1.3 向幻灯片中插入新文本框
'''

from pptx import Presentation
from pptx.util import Inches

ppt = Presentation()
# 空白布局
layout = ppt.slide_layouts[6]
# 添加空白布局的幻灯片
slide = ppt.slides.add_slide(layout)
# 预设位置以及大小
left = Inches(5)
top = Inches(5)
width = Inches(5)
height = Inches(5)
# left,top为相对位置，width,height为文本框大小
textbox = slide.shapes.add_textbox(left, top, width, height)
textbox.text = '这是一个新的文本框'
# 添加新段落
new_paragraph = textbox.text_frame.add_paragraph()
new_paragraph.text = '文本框中第二段内容'
ppt.save('add_new_text.pptx')